﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Emu8080.Compiler.Structures
{
    public class ImmediateOperand16bit
    {
        public enum ImmediateOperand16bitType
        {
            Label,
            Instruction,
            Number
        }

        public ImmediateOperand16bitType Type { get; set; }

        public object Value { get; set; }

        public ImmediateOperand16bit(string labelname)
        {
            Type = ImmediateOperand16bitType.Label;
            Value = labelname;
        }

        public ImmediateOperand16bit(IProcessingUnitFundamental instructionRef)
        {
            Type = ImmediateOperand16bitType.Instruction;
            Value = instructionRef;
        }

        public ImmediateOperand16bit(Int16 number)
        {
            Type = ImmediateOperand16bitType.Number;
            Value = number;
        }
    }

    public class CommandDbOperand
    {
        public enum CommandDbOperandType
        {
            String,
            NumberArray
        }

        public CommandDbOperandType Type { get; set; }

        public object Value { get; set; }

        public CommandDbOperand(string s)
        {
            Type = CommandDbOperandType.String;
            Value = s;
        }

        public CommandDbOperand(byte [] ba)
        {
            Type = CommandDbOperandType.NumberArray;
            Value = ba;
        }

        public int Size
        {
            get
            {
                if (Type == CommandDbOperandType.String)
                    return (Value as string).Length;
                else
                    return ((byte[])Value).Length;
            }
        }
    }
}
